package com.airforce.mappers;

import com.airforce.model.services;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface servicesMapper {
    @Delete({
        "delete from services",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into services (id, name, ",
        "code, createtime, ",
        "updatetime, isuse)",
        "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{code,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP}, ",
        "#{updatetime,jdbcType=TIMESTAMP}, #{isuse,jdbcType=TINYINT})"
    })
    int insert(services record);

    @InsertProvider(type=servicesSqlProvider.class, method="insertSelective")
    int insertSelective(services record);

    @Select({
        "select",
        "id, name, code, createtime, updatetime, isuse",
        "from services",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="code", property="code", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="isuse", property="isuse", jdbcType=JdbcType.TINYINT)
    })
    services selectByPrimaryKey(Integer id);

    @UpdateProvider(type=servicesSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(services record);

    @Update({
        "update services",
        "set name = #{name,jdbcType=VARCHAR},",
          "code = #{code,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=TIMESTAMP},",
          "updatetime = #{updatetime,jdbcType=TIMESTAMP},",
          "isuse = #{isuse,jdbcType=TINYINT}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(services record);

    @Select("select * from  services")
    List<services> selectByall();

    @Select("select * from  services where  name like #{name}")
    List<services> selectByname(String name);

    @Select("select id,name,code from  services where isuse=1")
    List<services> selectByisuse();
}